package com.bl.bean.network;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.spec.AlgorithmParameterSpec;
public class b
{
  private static byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8 };
  
//  public static String decryptDES(String paramString1, String paramString2)
//    throws Exception
//  {
//    if (paramString1==null || "".equals(paramString1)) {
//      return "";
//    }
//    IvParameterSpec localIvParameterSpec = new IvParameterSpec(iv);
//    Cipher localCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
//    localCipher.init(2, new SecretKeySpec(paramString2.getBytes(), "DES"), localIvParameterSpec);
//    return new String(localCipher.doFinal(a.decode(paramString1)));
//  }
  public static String decryptDES(String arg3, String arg4) throws Exception {
	  if (arg3==null || "".equals(arg3)) {
	      return "";
	    }
      byte[] v3 = a.decode(arg3);
      System.out.println(v3.length);
      IvParameterSpec v0 = new IvParameterSpec(b.iv);
      SecretKeySpec v1 = new SecretKeySpec(arg4.getBytes("utf-8"), "DES");
      Cipher v4 = Cipher.getInstance("DES/CBC/PKCS5Padding");
      v4.init(2, ((Key)v1), ((AlgorithmParameterSpec)v0));
      return new String(v4.doFinal(v3),"utf-8");
  }
  public static String encryptDES(String paramString1, String paramString2)
    throws Exception
  {
    IvParameterSpec localIvParameterSpec = new IvParameterSpec(iv);
    Cipher localCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
    localCipher.init(1, new SecretKeySpec(paramString2.getBytes("utf-8"), "DES"), localIvParameterSpec);
    return a.encode(localCipher.doFinal(paramString1.getBytes("utf-8")));
  }
}
